const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');

const packageInfo = require('./package.json');
const outputPath = './output/' + packageInfo.version;


module.exports = {
    entry: './entry.js',
    devtool: 'source-map',
    output: {
        path: outputPath,
        filename: 'bundle.js',
    },
    devServer: {
        inline: true,
        port: 7777
    },

    module: {
        loaders: [
            {test: /\.styl$/, loader: 'style!css!stylus'},
            {test: /\.css$/, loader: 'style!css'},
            {
                test: /\.js|jsx$/,
                exclude: /node_modules/,
                loaders: ['babel']
            }
        ]
    },

    plugins: [
        new webpack.DefinePlugin({
            'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
            API_PRODUCTION: JSON.stringify(false),
            VERSION: JSON.stringify("5fa3b9"),
            BROWSER_SUPPORTS_HTML5: true,
            TWO: "1+1",
            "typeof window": JSON.stringify("object")
        }),
        new HtmlWebpackPlugin({
            title: 'tally',
            filename: 'index.html',
            inject: true,
            minify: { //压缩HTML文件
                removeComments: true, //移除HTML中的注释
                collapseWhitespace: false //删除空白符与换行符
            }
        }),
    ]
};
